package com.bawei.day0129.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.bawei.day0129.Bean.JkzxBean;
import com.bawei.day0129.Bean.JkzxtabBean;
import com.bawei.day0129.Bean.XbBean;
import com.bawei.day0129.Bean.ZsBean;
import com.bawei.day0129.base.BaseViewModel;
import com.bawei.day0129.utils.HttpUtils;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * @author 11295 刘铠源
 * 2023/1/29 19:11
 * @类名 MainViewModel
 */
public class MainViewModel extends BaseViewModel {
    public MainViewModel(@NonNull Application application) {
        super(application);
    }
    private MutableLiveData<XbBean> liveData=new MutableLiveData<>();

    public MutableLiveData<XbBean> getLiveData() {
        HttpUtils.getHttpUtils().apisices.bannersShow().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<XbBean>() {
                    @Override
                    public void accept(XbBean xbBean) throws Exception {
                        liveData.postValue(xbBean);
                    }
                });
        return liveData;
    }
    private MutableLiveData<ZsBean> liveData2=new MutableLiveData<>();

    public MutableLiveData<ZsBean> getLiveData2() {
        HttpUtils.getHttpUtils().getApisices().findDepartment()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<ZsBean>() {
                    @Override
                    public void accept(ZsBean zsBean) throws Exception {
                        liveData2.postValue(zsBean);
                    }
                });
        return liveData2;
    }
    private MutableLiveData<JkzxtabBean> liveData3=new MutableLiveData<>();

    public MutableLiveData<JkzxtabBean> getLiveData3() {
        HttpUtils.getHttpUtils().getApisices().findInformationPlateList()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<JkzxtabBean>() {
                    @Override
                    public void accept(JkzxtabBean jkzxtabBean) throws Exception {
                        liveData3.postValue(jkzxtabBean);
                    }
                });
        return liveData3;
    }
    private MutableLiveData<JkzxBean> liveData4=new MutableLiveData<>();

    public MutableLiveData<JkzxBean> getLiveData4(int plateId,int a,int b) {
        HttpUtils.getHttpUtils().getApisices().findInformationList(plateId, a, b)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<JkzxBean>() {
                    @Override
                    public void accept(JkzxBean jkzxBean) throws Exception {
                        liveData4.postValue(jkzxBean);
                    }
                });
        return liveData4;
    }
}
